package com.dupt.system.service.impl;

import java.util.Collections;
import java.util.List;
import com.dupt.common.utils.DateUtils;
import com.dupt.system.domain.vo.MaterialSerialVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dupt.system.mapper.MaterialSerialMapper;
import com.dupt.system.domain.MaterialSerial;
import com.dupt.system.service.IMaterialSerialService;

/**
 * 物料序列号Service业务层处理
 * 
 * @author zhuanyu.sun
 * @date 2025-08-21
 */
@Service
public class MaterialSerialServiceImpl implements IMaterialSerialService
{
    @Autowired
    private MaterialSerialMapper materialSerialMapper;

    /**
     * 查询物料序列号
     * 
     * @param materialSerialId 物料序列号主键
     * @return 物料序列号
     */
    @Override
    public MaterialSerial selectMaterialSerialByMaterialSerialId(Long materialSerialId)
    {
        return materialSerialMapper.selectMaterialSerialByMaterialSerialId(materialSerialId);
    }

    /**
     * 批量查询物料序列号
     *
     * @param materialSerialIds 物料序列号主键
     * @return 物料序列号
     */
    @Override
    public List<MaterialSerial> selectMaterialSerialByMaterialSerialIds(Long[] materialSerialIds)
    {
        return materialSerialMapper.selectMaterialSerialByMaterialSerialIds(materialSerialIds);
    }

    /**
     * 根据序列号查询物料序列号信息
     *
     * @param serialNo 物料序列号
     * @return 物料序列号
     */
    @Override
    public List<MaterialSerial> selectMaterialSerialBySerialNo(String serialNo)
    {
        return materialSerialMapper.selectMaterialSerialBySerialNo(serialNo);
    }

    /**
     * 查询物料序列号列表
     * 
     * @param materialSerial 物料序列号
     * @return 物料序列号
     */
    @Override
    public List<MaterialSerial> selectMaterialSerialList(MaterialSerial materialSerial)
    {
        return materialSerialMapper.selectMaterialSerialList(materialSerial);
    }

    /**
     * 新增物料序列号
     * 
     * @param materialSerial 物料序列号
     * @return 结果
     */
    @Override
    public int insertMaterialSerial(MaterialSerial materialSerial)
    {
        materialSerial.setCreateTime(DateUtils.getNowDate());
        return materialSerialMapper.insertMaterialSerial(materialSerial);
    }

    /**
     * 修改物料序列号
     * 
     * @param materialSerial 物料序列号
     * @return 结果
     */
    @Override
    public int updateMaterialSerial(MaterialSerial materialSerial)
    {
        materialSerial.setUpdateTime(DateUtils.getNowDate());
        return materialSerialMapper.updateMaterialSerial(materialSerial);
    }

    /**
     * 修改物料序列号
     *
     * @param materialSerialList 物料序列号
     * @return 结果
     */
    @Override
    public int batchUpdateMaterialSerial(List<MaterialSerial> materialSerialList)
    {
        return materialSerialMapper.batchUpdateMaterialSerial(materialSerialList);
    }

    /**
     * 批量删除物料序列号
     * 
     * @param materialSerialIds 需要删除的物料序列号主键
     * @return 结果
     */
    @Override
    public int deleteMaterialSerialByMaterialSerialIds(Long[] materialSerialIds)
    {
        return materialSerialMapper.deleteMaterialSerialByMaterialSerialIds(materialSerialIds);
    }

    /**
     * 删除物料序列号信息
     * 
     * @param materialSerialId 物料序列号主键
     * @return 结果
     */
    @Override
    public int deleteMaterialSerialByMaterialSerialId(Long materialSerialId)
    {
        return materialSerialMapper.deleteMaterialSerialByMaterialSerialId(materialSerialId);
    }

    /**
     * 根据物料收集ID查询物料序列号信息
     *
     * @param materialCollectId 物料收集ID
     * @return 物料序列号信息
     */
    @Override
    public List<MaterialSerialVo> receiveSearchMaterialByMaterialCollectId(Long materialCollectId) {

        return materialSerialMapper.receiveSearchMaterialByMaterialCollectId(materialCollectId);
    }

    /****
     * 根据组装用料ID查询物料序列号信息
     *
     * @param assembleMaterialId 组装用料ID
     * @return 物料序列号信息
     */
    @Override
    public List<MaterialSerialVo> sendBackSearchMaterialSerialByAssembleMaterialId(Long assembleMaterialId) {
        return materialSerialMapper.sendBackSearchMaterialSerialByAssembleMaterialId(assembleMaterialId);
    }
}
